package bTree.LeetCode;

public class 二进制求和 {
    public String addBinary(String a, String b) {
        int length1 = a.length();
        int length2 = b.length();
        int i = length1 - 1, j = length2 - 1, path = 0;
        String s = new String();
        while (i >= 0 || j >= 0||path!=0) {
            if (i >= 0) {
                path += a.charAt(i) - '0';
                i--;
            }
            if (j >= 0) {
                path += b.charAt(j) - '0';
                j--;
            }
            String string = String.valueOf(path % 2 );
            path=path/2;
            s=string+s;
        }

        return s;
    }
}

